package com.lixin.smartclassroom.ui.home.tab5.activity

import com.drake.net.utils.scopeNetLife
import com.lixin.smartclassroom.api.aboutUs
import com.lixin.smartclassroom.databinding.ActivityContactUsBinding
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.copyToClip
import com.lixinkeji.extension.load
import com.lixinkeji.extension.onClick
import com.lixinkeji.extension.openDial
import com.lixinkeji.extension.start

/**
 * Description 联系我们
 * Author: lwc
 * Date:2023/12/9 9:58
 */
class ContactUsAct : BaseActivity<ActivityContactUsBinding>() {
    override fun getViewBinding() = ActivityContactUsBinding.inflate(layoutInflater)

    override fun topBarHide() = false
    override fun startPadding() = true
    override fun title() = "联系我们"
    private var wxCodeUrl = ""

    override fun iniView() {
        binding.apply {
            scopeNetLife {
                val baseBean = aboutUs()
                if (baseBean.result == "0") {
                    tvWx.text = baseBean.weixin
                    tvPhone.text = baseBean.phone
                    tvEmail.text = baseBean.address
                    imgWxCode.load(baseBean.weixincode!!)
                    wxCodeUrl = baseBean.weixincode!!
                }
            }
        }
    }

    override fun onClick() {
        binding.apply {
            btnPreview.onClick {
                start(QrCodePreviewAct::class.java) {
                    putExtra("url", wxCodeUrl)
                }
            }

            btnCall.onClick {
                openDial(tvPhone.text.toString())
            }
            btnCopyWx.onClick {
                tvWx.text.toString().copyToClip(this@ContactUsAct)
            }

            btnCopyEmail.onClick {
                tvEmail.text.toString().copyToClip(this@ContactUsAct)
            }
        }
    }


}